<template>
  <div class="add">
    <div class="type">
      <span class="iconfont" @click="goto()">&#xe779;</span>
      收货地址
    </div>
    <router-link to="/add">
    <div class="bot">
      <p>添加新地址</p>
    </div>
        </router-link>
    <div class="dizhi">
      <div class="dz" v-for="(item, index) in dz">
        <div class="sh" @click="myshdz(index),goto()">
          <p>收货人：{{ item.name }}</p>
          <span>{{ item.dh }}</span>
          <p>收货地址：{{ item.sh }}</p>
        </div>

        <div class="mr">
          <div @click="mr(index)">
            <span class="iconfont" :class="index == mrdz ? 'active' : ''"
              >&#xe615;</span
            >
            <p>默认地址</p>
          </div>
          <div>
            <span class="iconfont">&#xe6a0;</span>
            <p @click="remo(index)">删除</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.add {
  .type {
    text-align: center;
    line-height: 50px;
    font-size: 16px;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 9999;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    color: rgb(116, 116, 116);
    text-align: center;
    background-color: white;
    span {
      position: absolute;
      display: block;
      height: 50px;
      width: 40px;
    }
    a {
      display: block;
      span {
        position: absolute;
        display: block;
        height: 50px;
        color: rgb(116, 116, 116);
        font-size: 25px;
        width: 40px;
        right: 0;
        top: 0;
      }
    }
  }
  .bot {
    position: fixed;
    bottom: 0;
    background-color: red;
    height: 60px;
    width: 100%;
    z-index: 9999999;
    text-align: center;
    line-height: 60px;
    p {
      font-size: 16px;
      color: white;
    }
  }
  .dizhi {
    margin-top: 50px;
    background-color: rgb(235, 235, 235);
    .dz {
      position: relative;
      background-color: white;
      padding: 0 10px;
      margin-top: 10px;
      .sh {
        p {
          color: rgb(116, 116, 116);
          font-size: 16px;
          padding-top: 10px;
        }
        span {
          right: 10px;
          position: absolute;
          color: rgb(116, 116, 116);
          font-size: 14px;
          top: 10px;
        }
      }
      .mr {
        position: relative;
        margin-top: 20px;
        border-top: 1px solid #ccc;
        border-bottom: 1px solid #ccc;
        padding: 10px 0;
        div {
          display: flex;
          span {
            color: rgb(116, 116, 116);
            font-size: 20px;
          }
          p {
            color: rgb(116, 116, 116);
            font-size: 16px;
            margin-left: 5px;
            padding-top: 2px;
          }
        }
        .active {
          background-color: orangered !important;
          border: 1px solid orangered !important;
        }
        div:nth-child(2) {
          position: absolute;
          right: 10px;
          top: 10px;
        }
        div:nth-child(1) span {
          height: 20px;
          width: 20px;
          background-color: white;
          border: 1px solid #ccc;
          color: white;
          border-radius: 50%;
        }
      }
    }
  }
}
</style>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "add",
  methods: {
    goto() {
      this.$router.go(-1);
    },
    ...mapMutations(["mr", "myshdz",'remo']),
  },
  computed: {
    ...mapState(["dz", "mrdz"]),
  },
};
</script>